//
//  LicenceView.m
//  项目三
//
//  Created by rimi on 15/10/9.
//  Copyright (c) 2015年 rimi. All rights reserved.
//

#import "LicenceView.h"

@interface LicenceView() 

@property (nonatomic, strong) UIImageView *backgroundImage;
@property (nonatomic, strong) UIButton *confirmBtn;
@property (nonatomic, strong) UIButton *chooseAllBtn;
@property (nonatomic, strong) UIButton *payBtn;
@property (nonatomic, strong) UIButton *cancelBtn;
@property (nonatomic, strong) UIButton *typeBtn;
@property (nonatomic, strong) UIButton *placeBtn;
@property (nonatomic, strong) UIImageView *license;
@property (nonatomic, strong) UITextField *carNum;
@property (nonatomic, strong) UITextField *mechineNum;

- (void)initializeAppearence;
@end

@implementation LicenceView

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self initializeAppearence];
    }
    return self;
}

- (instancetype)init {
    self = [super init];
    if (self) {
        [self initializeAppearence];
    }
    return self;
}

- (void)initializeAppearence {

    [self addSubview:self.backgroundImage];
    [self addSubview:self.confirmBtn];
    [self addSubview:self.chooseAllBtn];
    [self addSubview:self.payBtn];
    [self addSubview:self.cancelBtn];
    [self addSubview:self.license];
    [self addSubview:self.typeBtn];
    [self addSubview:self.placeBtn];
    [self addSubview:self.carNum];
    [self addSubview:self.mechineNum];
}
#pragma mark - action on button
- (void)actionOnConfirmBtn {


}
- (void)actionOnChooseBtn {


}
- (void)actionOnPayBtn {


}
- (void)actionOnCancelBtn {
    
    [UIView animateWithDuration:1.0 animations:^{
        self.alpha = 0;
    }];
    [self removeFromSuperview];
}
- (void)actionOnTypeBtn {


}
- (void)actionOnPlaceBtn {

    
}

#pragma mark - getter
- (UIImageView *)backgroundImage {
    
    if (!_backgroundImage) {
        _backgroundImage = ({
            
            UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.bounds];
            imageView.image = [UIImage imageNamed:@"灰色背景"];
            
            imageView;
        });
    }
    return _backgroundImage;
}

- (UIButton *)confirmBtn {

    if (!_confirmBtn) {
        _confirmBtn = ({
        
            UIButton *button = [[UIButton alloc] initWithFrame:DHFlexibleFrame(CGRectMake(260, 190, 122, 45))];
            [button setImage:[UIImage imageNamed:@"购买确定"] forState:UIControlStateNormal];
            [button addTarget:self action:@selector(actionOnConfirmBtn) forControlEvents:UIControlEventTouchUpInside];
            
            button;
        });
    }
    return _confirmBtn;
}
- (UIButton *)chooseAllBtn {

    if (!_chooseAllBtn) {
        _chooseAllBtn = ({
        
            UIButton *button = [[UIButton alloc] initWithFrame:DHFlexibleFrame(CGRectMake(130, 568, 143, 48))];
            [button setImage:[UIImage imageNamed:@"全选1"] forState:UIControlStateNormal];
            [button addTarget:self action:@selector(actionOnChooseBtn) forControlEvents:UIControlEventTouchUpInside];
            
            button;

        });
    }
    return _chooseAllBtn;
}
- (UIButton *)payBtn {

    if (!_payBtn) {
        _payBtn = ({
        
            UIButton *button = [[UIButton alloc] initWithFrame:DHFlexibleFrame(CGRectMake(290, 568, 143, 48))];
            [button setImage:[UIImage imageNamed:@"缴付罚款"] forState:UIControlStateNormal];
            [button addTarget:self action:@selector(actionOnPayBtn) forControlEvents:UIControlEventTouchUpInside];
            
            button;

        });
    }
    return _payBtn;
}
- (UIButton *)cancelBtn {

    if (!_cancelBtn) {
        _cancelBtn = ({
        
            UIButton *button = [[UIButton alloc] initWithFrame:DHFlexibleFrame(CGRectMake(450, 568, 143, 48))];
            [button setImage:[UIImage imageNamed:@"缴费取消"] forState:UIControlStateNormal];
            [button addTarget:self action:@selector(actionOnCancelBtn) forControlEvents:UIControlEventTouchUpInside];
            
            button;

        });
    }
    return _cancelBtn;
}
- (UIButton *)typeBtn {

    if (!_typeBtn) {
        _typeBtn = ({
        
            UIButton *button = [[UIButton alloc] initWithFrame:DHFlexibleFrame(CGRectMake(249, 35, 188, 47))];
            [button setImage:[UIImage imageNamed:@"多选按钮"] forState:UIControlStateNormal];
            [button setTitle:@"车车" forState:UIControlStateNormal];
            [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            button.titleEdgeInsets = UIEdgeInsetsMake(10, -280, 10, 0);
            [button addTarget:self action:@selector(actionOnTypeBtn) forControlEvents:UIControlEventTouchUpInside];
            
            button;

        });
    }
    return _typeBtn;
}
- (UIButton *)placeBtn {

    if (!_placeBtn) {
        _placeBtn = ({
        
            UIButton *button = [[UIButton alloc] initWithFrame:DHFlexibleFrame(CGRectMake(247, 84, 60, 48))];
            [button setImage:[UIImage imageNamed:@"多选按钮"] forState:UIControlStateNormal];
            [button setTitle:@"车" forState:UIControlStateNormal];
            [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            button.titleEdgeInsets = UIEdgeInsetsMake(10, -180, 10, 0);
            [button addTarget:self action:@selector(actionOnPlaceBtn) forControlEvents:UIControlEventTouchUpInside];
            
            button;

        });
    }
    return _placeBtn;
}
- (UIImageView *)license {

    if (!_license) {
        _license = ({
        
            UIImageView *imageView = [[UIImageView alloc] initWithFrame:DHFlexibleFrame(CGRectMake(148, 39, 300, 137))];
            imageView.image = [UIImage imageNamed:@"车牌种类"];
            
            imageView;
        });
    }
    return _license;
}
- (UITextField *)carNum {

    if (!_carNum) {
        _carNum = ({
        
            UITextField *textField = [[UITextField alloc] initWithFrame:DHFlexibleFrame(CGRectMake(332, 94, 110, 27))];
            
            textField;
        });
    }
    return _carNum;
}
- (UITextField *)mechineNum {

    if (!_mechineNum) {
        _mechineNum = ({
        
            UITextField *textField = [[UITextField alloc] initWithFrame:DHFlexibleFrame(CGRectMake(255, 147, 145, 25))];
            
            textField;
        });
    }
    return _mechineNum;
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    [self endEditing:YES];
}
@end
